package github.kawaiior.yuanchuxiuzhen.common.entity.addon.model;

import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import github.kawaiior.yuanchuxiuzhen.common.entity.addon.ThunderDeerEntity;
import github.kawaiior.yuanchuxiuzhen.util.RenderUtil;
import net.minecraft.client.renderer.entity.model.EntityModel;
import net.minecraft.client.renderer.model.ModelRenderer;
import net.minecraft.util.math.MathHelper;

public class ThunderDeerEntityModel extends EntityModel<ThunderDeerEntity> {
    private final ModelRenderer head;

    private final ModelRenderer bone15;

    private final ModelRenderer bone14;

    private final ModelRenderer bone16;

    private final ModelRenderer bone17;

    private final ModelRenderer bone18;

    private final ModelRenderer bone19;

    private final ModelRenderer bone20;

    private final ModelRenderer bone25;

    private final ModelRenderer bone24;

    private final ModelRenderer bone21;

    private final ModelRenderer bone23;

    private final ModelRenderer bone22;

    private final ModelRenderer rightarm;

    private final ModelRenderer bone2;

    private final ModelRenderer bone5;

    private final ModelRenderer bone31;

    private final ModelRenderer bone4;

    private final ModelRenderer leftarm;

    private final ModelRenderer bone30;

    private final ModelRenderer bone3;

    private final ModelRenderer bone7;

    private final ModelRenderer bone6;

    private final ModelRenderer body;

    private final ModelRenderer bone;

    private final ModelRenderer bone8;

    private final ModelRenderer bone13;

    private final ModelRenderer rightleg;

    private final ModelRenderer bone27;

    private final ModelRenderer bone29;

    private final ModelRenderer bone11;

    private final ModelRenderer bone9;

    private final ModelRenderer leftleg;

    private final ModelRenderer bone12;

    private final ModelRenderer bone26;

    private final ModelRenderer bone10;

    private final ModelRenderer bone28;
    public ThunderDeerEntityModel(){
        this.textureWidth=64;
        this.textureHeight=64;
        this.head=new ModelRenderer(this);
        this.head.setRotationPoint(0.0F,2.0F,-12.0F);
        this.bone15=new ModelRenderer(this);
        this.bone15.setRotationPoint(0.0F,22.0F,12.0F);
        this.head.addChild(this.bone15);
        addBox(this.bone15, 0, 0, -3.0F, -35.0F, -19.0F, 6, 5, 6, 0.0F, false);
        this.bone14=new ModelRenderer(this);
        this.bone14.setRotationPoint(-1.0F,17.0F,22.0F);
        RenderUtil.setRotationAngle(this.bone14,0.2618F,0.0F,0.0F);
        this.head.addChild(this.bone14);
        addBox(this.bone14, 12, 11, -1.0F, -32.0F, -18.0F, 4, 11, 3, 0.0F, false);
        this.bone16=new ModelRenderer(this);
        this.bone16.setRotationPoint(0.0F,22.0F,12.0F);
        this.head.addChild(this.bone16);
        addBox(this.bone16, 0, 11, -1.0F, -32.0F, -23.0F, 2, 2, 4, 0.0F, false);
        this.bone17=new ModelRenderer(this);
        this.bone17.setRotationPoint(0.0F,15.0F,17.0F);
        RenderUtil.setRotationAngle(this.bone17,0.1745F,0.0F,0.0F);
        this.head.addChild(this.bone17);
        addBox(this.bone17, 0, 17, -1.0F, -29.8415F, -23.1888F, 2, 1, 4, 0.0F, false);
        this.bone18=new ModelRenderer(this);
        this.bone18.setRotationPoint(-6.0F,25.0F,5.0F);
        RenderUtil.setRotationAngle(this.bone18,-0.1745F,0.0F,0.1745F);
        this.head.addChild(this.bone18);
        addBox(this.bone18, 0, 22, 2.0F, -40.6527F, -15.9696F, 1, 5, 1, 0.0F, false);
        this.bone19=new ModelRenderer(this);
        this.bone19.setRotationPoint(1.0F,26.0F,5.0F);
        RenderUtil.setRotationAngle(this.bone19,-0.1745F,0.0F,-0.1745F);
        this.head.addChild(this.bone19);
        addBox(this.bone19, 0, 22, 2.0F, -40.6527F, -15.9696F, 1, 5, 1, 0.0F, false);
        this.bone20=new ModelRenderer(this);
        this.bone20.setRotationPoint(1.0F,7.0F,35.0F);
        RenderUtil.setRotationAngle(this.bone20,0.6981F,0.0F,0.0F);
        this.head.addChild(this.bone20);
        addBox(this.bone20, 0, 22, -5.0F, -45.2856F, -15.5321F, 1, 3, 1, 0.0F, false);
        addBox(this.bone20, 0, 22, 2.0F, -45.2856F, -15.5321F, 1, 3, 1, 0.0F, false);
        this.bone25=new ModelRenderer(this);
        this.bone25.setRotationPoint(-9.0F,26.0F,-3.0F);
        RenderUtil.setRotationAngle(this.bone25,0.0F,0.0F,-0.1745F);
        this.head.addChild(this.bone25);
        addBox(this.bone25, 0, 0, 11.0F, -38.0F, 0.0F, 2, 2, 1, 0.0F, false);
        this.bone24=new ModelRenderer(this);
        this.bone24.setRotationPoint(-15.0F,22.0F,-3.0F);
        RenderUtil.setRotationAngle(this.bone24,0.0F,0.0F,0.1745F);
        this.head.addChild(this.bone24);
        addBox(this.bone24, 0, 0, 11.0F, -38.0F, 0.0F, 2, 2, 1, 0.0F, false);
        this.bone21=new ModelRenderer(this);
        this.bone21.setRotationPoint(1.0F,27.0F,-10.0F);
        RenderUtil.setRotationAngle(this.bone21,-0.5236F,0.0F,0.0F);
        this.head.addChild(this.bone21);
        addBox(this.bone21, 0, 22, -5.0F, -46.0F, -15.7321F, 1, 6, 1, 0.0F, false);
        addBox(this.bone21, 0, 22, 2.0F, -46.0F, -15.7321F, 1, 6, 1, 0.0F, false);
        this.bone23=new ModelRenderer(this);
        this.bone23.setRotationPoint(22.0F,10.0F,12.0F);
        RenderUtil.setRotationAngle(this.bone23,0.0F,0.0F,-0.8727F);
        this.head.addChild(this.bone23);
        addBox(this.bone23, 0, 22, 3.0F, -41.0F, -16.0F, 1, 4, 1, 0.0F, false);
        this.bone22=new ModelRenderer(this);
        this.bone22.setRotationPoint(-27.0F,6.0F,12.0F);
        RenderUtil.setRotationAngle(this.bone22,0.0F,0.0F,0.8727F);
        this.head.addChild(this.bone22);
        addBox(this.bone22, 0, 22, 3.0F, -41.0F, -16.0F, 1, 4, 1, 0.0F, false);
        this.rightarm=new ModelRenderer(this);
        this.rightarm.setRotationPoint(-4.0F,9.0F,-9.0F);
        this.bone2=new ModelRenderer(this);
        this.bone2.setRotationPoint(4.0F,15.0F,9.0F);
        this.rightarm.addChild(this.bone2);
        addBox(this.bone2, 0, 43, -5.0F, -17.0F, -11.0F, 2, 4, 4, 0.0F, false);
        this.bone5=new ModelRenderer(this);
        this.bone5.setRotationPoint(-4.0F,24.0F,8.0F);
        RenderUtil.setRotationAngle(this.bone5,-0.0873F,0.0F,0.0F);
        this.rightarm.addChild(this.bone5);
        addBox(this.bone5, 12, 43, 3.0F, -16.0038F, -9.9128F, 2, 7, 2, 0.0F, false);
        this.bone31=new ModelRenderer(this);
        this.bone31.setRotationPoint(4.0F,15.0F,9.0F);
        this.rightarm.addChild(this.bone31);
        addBox(this.bone31, 0, 32, -5.0F, -1.0F, -11.0F, 2, 1, 2, 0.0F, false);
        this.bone4=new ModelRenderer(this);
        this.bone4.setRotationPoint(-4.0F,16.0F,10.0F);
        RenderUtil.setRotationAngle(this.bone4,0.0873F,0.0F,0.0F);
        this.rightarm.addChild(this.bone4);
        addBox(this.bone4, 0, 51, 3.0F, -16.0038F, -10.0872F, 2, 7, 3, 0.0F, false);
        this.leftarm=new ModelRenderer(this);
        this.leftarm.setRotationPoint(4.0F,9.0F,-9.0F);
        this.bone30=new ModelRenderer(this);
        this.bone30.setRotationPoint(-4.0F,15.0F,9.0F);
        this.leftarm.addChild(this.bone30);
        addBox(this.bone30, 0, 43, 3.0F, -17.0F, -11.0F, 2, 4, 4, 0.0F, false);
        this.bone3=new ModelRenderer(this);
        this.bone3.setRotationPoint(-4.0F,16.0F,10.0F);
        RenderUtil.setRotationAngle(this.bone3,0.0873F,0.0F,0.0F);
        this.leftarm.addChild(this.bone3);
        addBox(this.bone3, 0, 51, 3.0F, -16.0038F, -10.0872F, 2, 7, 3, 0.0F, false);
        this.bone7=new ModelRenderer(this);
        this.bone7.setRotationPoint(-4.0F,15.0F,9.0F);
        this.leftarm.addChild(this.bone7);
        addBox(this.bone7, 0, 32, 3.0F, -1.0F, -11.0F, 2, 1, 2, 0.0F, false);
        this.bone6=new ModelRenderer(this);
        this.bone6.setRotationPoint(-4.0F,24.0F,8.0F);
        RenderUtil.setRotationAngle(this.bone6,-0.0873F,0.0F,0.0F);
        this.leftarm.addChild(this.bone6);
        addBox(this.bone6, 12, 43, 3.0F, -16.0038F, -9.9128F, 2, 7, 2, 0.0F, false);
        this.body=new ModelRenderer(this);
        this.body.setRotationPoint(0.0F,24.0F,0.0F);
        this.bone=new ModelRenderer(this);
        this.bone.setRotationPoint(0.0F,0.0F,0.0F);
        this.body.addChild(this.bone);
        addBox(this.bone, 26, 0, -4.0F, -22.0F, -13.0F, 8, 8, 8, 0.0F, false);
        addBox(this.bone, 0, 25, -4.0F, -22.0F, 2.0F, 8, 8, 10, 0.0F, false);
        this.bone8=new ModelRenderer(this);
        this.bone8.setRotationPoint(0.0F,0.0F,0.0F);
        this.body.addChild(this.bone8);
        addBox(this.bone8, 26, 16, -4.0F, -22.0F, -5.0F, 8, 6, 7, 0.0F, false);
        this.bone13=new ModelRenderer(this);
        this.bone13.setRotationPoint(0.0F,3.0F,15.0F);
        RenderUtil.setRotationAngle(this.bone13,0.6109F,0.0F,0.0F);
        this.body.addChild(this.bone13);
        addBox(this.bone13, 18, 0, -1.0F, -23.0F, 11.0F, 2, 2, 3, 0.0F, false);
        this.rightleg=new ModelRenderer(this);
        this.rightleg.setRotationPoint(-4.0F,8.0F,7.0F);
        this.bone27=new ModelRenderer(this);
        this.bone27.setRotationPoint(4.0F,17.0F,-4.0F);
        RenderUtil.setRotationAngle(this.bone27,0.1745F,0.0F,0.0F);
        this.rightleg.addChild(this.bone27);
        addBox(this.bone27, 20, 43, -5.0F, -13.1736F, 4.0152F, 2, 6, 4, 0.0F, false);
        this.bone29=new ModelRenderer(this);
        this.bone29.setRotationPoint(4.0F,16.0F,8.0F);
        this.rightleg.addChild(this.bone29);
        addBox(this.bone29, 54, 60, -5.0F, -1.0F, -11.0F, 2, 1, 3, 0.0F, false);
        this.bone11=new ModelRenderer(this);
        this.bone11.setRotationPoint(1.0F,13.0F,-8.0F);
        RenderUtil.setRotationAngle(this.bone11,-0.1745F,0.0F,0.0F);
        this.rightleg.addChild(this.bone11);
        addBox(this.bone11, 32, 43, -2.0F, -6.0152F, 6.1736F, 2, 7, 3, 0.0F, false);
        this.bone9=new ModelRenderer(this);
        this.bone9.setRotationPoint(4.0F,16.0F,-7.0F);
        this.rightleg.addChild(this.bone9);
        addBox(this.bone9, 36, 29, -5.0F, -19.0F, 4.0F, 2, 6, 6, 0.0F, false);
        this.leftleg=new ModelRenderer(this);
        this.leftleg.setRotationPoint(4.0F,8.0F,7.0F);
        this.bone12=new ModelRenderer(this);
        this.bone12.setRotationPoint(-4.0F,16.0F,8.0F);
        this.leftleg.addChild(this.bone12);
        addBox(this.bone12, 54, 60, 3.0F, -1.0F, -11.0F, 2, 1, 3, 0.0F, false);
        this.bone26=new ModelRenderer(this);
        this.bone26.setRotationPoint(-7.0F,13.0F,-8.0F);
        RenderUtil.setRotationAngle(this.bone26,-0.1745F,0.0F,0.0F);
        this.leftleg.addChild(this.bone26);
        addBox(this.bone26, 32, 43, 6.0F, -6.0152F, 6.1736F, 2, 7, 3, 0.0F, false);
        this.bone10=new ModelRenderer(this);
        this.bone10.setRotationPoint(-4.0F,17.0F,-4.0F);
        RenderUtil.setRotationAngle(this.bone10,0.1745F,0.0F,0.0F);
        this.leftleg.addChild(this.bone10);
        addBox(this.bone10, 20, 43, 3.0F, -13.1736F, 4.0152F, 2, 6, 4, 0.0F, false);
        this.bone28=new ModelRenderer(this);
        this.bone28.setRotationPoint(-4.0F,16.0F,-7.0F);
        this.leftleg.addChild(this.bone28);
        addBox(this.bone28, 36, 29, 3.0F, -19.0F, 4.0F, 2, 6, 6, 0.0F, false);
    }

    private void addBox(ModelRenderer mb, int tx, int ty, float x, float y, float z, float width, float height, float depth, float delta, boolean mirrorIn){
        ModelRenderer mr = new ModelRenderer(this);
        mb.addChild(mr);
        mr.setTextureOffset(tx, ty).addBox(x,y,z,width,height,depth,delta,mirrorIn);
    }

    @Override
    public void setRotationAngles(ThunderDeerEntity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {
        this.head.rotateAngleY = netHeadYaw / 57.295776F;
        this.head.rotateAngleX = headPitch / 57.295776F;
        this.rightleg.rotateAngleX = MathHelper.cos(limbSwing * 1.0F) * -1.0F * limbSwingAmount;
        this.rightarm.rotateAngleX = MathHelper.cos(limbSwing * 1.0F) * 1.0F * limbSwingAmount;
        this.leftleg.rotateAngleX = MathHelper.cos(limbSwing * 1.0F) * 1.0F * limbSwingAmount;
        this.leftarm.rotateAngleX = MathHelper.cos(limbSwing * 1.0F) * -1.0F * limbSwingAmount;
    }

    @Override
    public void render(MatrixStack matrixStackIn, IVertexBuilder bufferIn, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) {
        this.head.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn);
        this.rightarm.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn);
        this.leftarm.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn);
        this.body.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn);
        this.rightleg.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn);
        this.leftleg.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn);
    }
}
